let ids = lib.eachId(args);

if(ids && ids.length > 0){
    for(let id of ids){
        let type = lib.dbQueryJsonArray(`SELECT
			type 
		FROM
			adjustment_order ao
		WHERE
			ao.id = ? 
			AND ao.del_flag = 0`,id);
		if(type[0].type == "0"){
		let trans = lib.newTransaction();
			try{
				lib.serviceInvoke("adjustmentOrderServiceImpl","bad",id);
				lib.serviceInvoke("adjustmentOrderServiceImpl","good",id);
				trans.commit();
			}catch(e){
				lib.addUserMessage("单据异常："+e);
				trans.rollback();
			}
		
		}else if(type[0].type == "1"){
			let trans = lib.newTransaction();
			try{
				lib.serviceInvoke("adjustmentOrderServiceImpl","lockStockOut",id);
				lib.serviceInvoke("adjustmentOrderServiceImpl","stockIn",id);
				trans.commit();
			}catch(e){
				lib.addUserMessage("单据异常："+e);
				trans.rollback();
			}	
		}
    }
}
